$('document').ready(function () {
    $('.head').append(`
        <div class="top">
            <a href="login.html" >登录</a>
        </div>
        <ul>
            <li>
                <a href="carousel_manage.html">轮播管理</a>
            </li>
            <li>
                <a href="pet_manage.html">宠物管理</a>
            </li>
            <li>
                <a href="kind_manage.html">宠物分类管理</a>
            </li>
            <li>
                <a href="mine.html">我的</a>
            </li>
        </ul>
    `)

    let admin = getSession('admin')

    if(admin){
        $('.head .top').html(`
            <span style="margin-right:20px;">欢迎${admin.username}</span>

            <a id="out" href="#">注销</a>
        `)

        $('#out').click(function(){
            removeSession('admin')

            alert("退出成功")
            location.href = "login.html"
        })
    }

    else{
        let theUrl = location.href

        let res = theUrl.search("login.html")
        console.log(res)
        
        if(res < 0){
            alert("请先登录")
            location.href ="login.html"
        }
    }

    
})